/*******************************************************************************************************

Figure 5: Difference-in-differences estimates using Tilly's public protest data

*******************************************************************************************************/

clear all

*read in our main dataset
use dta\didtilly1_rep.dta /// dataset with events with circle of same radius as the constituency

*Elminate contrituencies which are not part of case G
drop if ID == 45 //University of Cambridge
drop if ID == 191 //University of Oxford
keep if new == 1 | drummond == .

gen treatgroup = 0
replace treatgroup =  1 if new==1 

gen treatinter = treatperiod*treatgroup

gen logPNUM_all  = log(PNUM_all  + 1)
gen logPNUM_peace  = log(PNUM_peace  + 1)
gen logPNUM_violent  = log(PNUM_violent  + 1)



gen year = treatperiod
tsset ID year

/*
gen treatinterL0 =treatinter
label var treatinterL0 "Log people (all)"
xtreg logPNUM_all   treatinterL1 $control2 i.year, fe cluster(ID)
estimates store mL0
*/
gen treatinterL1 =treatinter
label var treatinterL1 "Log people (violent)"
xtreg logPNUM_violent   treatinterL1 $control2 i.year, fe cluster(ID)
estimates store mL1

gen treatinterL2 =treatinter
label var treatinterL2 "Log people (peaceful)"
xtreg logPNUM_peace   treatinterL2 $control2 i.year, fe cluster(ID)
estimates store mL2

/*
gen treatinterL5 =treatinter
label var treatinterL5 "Events (all)"
xtreg event_all   treatinterL3 $control1 i.year, fe cluster(ID)
estimates store mL5
*/

gen treatinterL3 =treatinter
label var treatinterL3 "Events (violent)"
xtreg event_violent   treatinterL3 $control1 i.year, fe cluster(ID)
estimates store mL3


gen treatinterL4 =treatinter
label var treatinterL4 "Events (peaceful)"
xtreg event_peace   treatinterL4 $control1 i.year, fe cluster(ID)
estimates store mL4


set scheme plotplainblind

coefplot mL1 mL2 mL3 mL4, ///
    drop(_cons) ///
    keep(treatinterL1 treatinterL2 treatinterL3 treatinterL4) ///
    ci(90) ///
    msymbol(O) mcolor(black) mlcolor(black) ///  points in black (fill + outline)
    ciopts(lcolor(black) lwidth(medthin))    ///  CI lines in black
    xline(0, lcolor(gs8))                    ///  zero line in grey
    legend(off)

graph export "graphs\figure5a.pdf", as(pdf) name("Graph") replace

stop

clear all

*read in our main dataset
use dta\didtilly2_rep.dta /// dataset with events with circle of same radius as the constituency

*Elminate contrituencies which are not part of case G
drop if ID == 45 //University of Cambridge
drop if ID == 191 //University of Oxford
keep if sch_A==1 | sch_B == 1 | drummond!=.

gen treatgroup = 0
replace treatgroup =  1 if sch_A==1 


gen treatinter = treatperiod*treatgroup

gen logPNUM_all  = log(PNUM_all  + 1)
gen logPNUM_peace  = log(PNUM_peace  + 1)


gen year = treatperiod
tsset ID year

gen treatinterL1 =treatinter
label var treatinterL1 "Log people (all)"
xtreg logPNUM_all   treatinterL1 $control2 i.year, fe cluster(ID)
estimates store mL1

gen treatinterL2 =treatinter
label var treatinterL2 "Log people (peaceful)"
xtreg logPNUM_peace   treatinterL2 $control2 i.year, fe cluster(ID)
estimates store mL2

gen treatinterL3 =treatinter
label var treatinterL3 "Events (all)"
xtreg event_all   treatinterL3 $control1 i.year, fe cluster(ID)
estimates store mL3


gen treatinterL4 =treatinter
label var treatinterL4 "Events (peaceful)"
xtreg event_peace   treatinterL4 $control1 i.year, fe cluster(ID)
estimates store mL4


set scheme plotplainblind

coefplot mL1 mL2 mL3 mL4, ///
    drop(_cons) ///
    keep(treatinterL1 treatinterL2 treatinterL3 treatinterL4) ///
    ci(90) ///
    msymbol(O) mcolor(black) mlcolor(black) ///  points in black (fill + outline)
    ciopts(lcolor(black) lwidth(medthin))    ///  CI lines in black
    xline(0, lcolor(gs8))                    ///  zero line in grey
    legend(off)

graph export "graphs\figure5b.pdf", as(pdf) name("Graph") replace



